package com.xone.xapp;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class AssistantActivity extends BasicActivity {

	@Override
	public int getContentView() {
		return R.layout.assistent;
	}
	@Override
	public String getHeaderTitle() {
		return getTitleByLevel("我的伙计");
	}
	@Override
	public void leftButton(Button leftButton) {
		leftButton.setText("首页");
		leftButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(getContext(), GuideActivity.class);
				startActivity(i);
			}
		});
	}
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//权限控制
		if (UserInfo.alevelUser || UserInfo.blevelUser) {//售卖发布可见
			findViewById(R.id.to_sale_area).setVisibility(View.VISIBLE);
			if (UserInfo.alevelUser) {//组团发布可见
				findViewById(R.id.product_create_line_2).setVisibility(View.VISIBLE);
				findViewById(R.id.product_create_type_2).setVisibility(View.VISIBLE);
			}
			findViewById(R.id.support_create_line_0).setVisibility(View.VISIBLE);
			findViewById(R.id.support_create_type_0).setVisibility(View.VISIBLE);
		}
		if (UserInfo.blevelUser || UserInfo.clevelUser) {
			findViewById(R.id.to_purchase_area).setVisibility(View.VISIBLE);
		}
		View productType0 = findViewById(R.id.product_create_type_0);
		productType0.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(AssistantActivity.this, ProductCreateActivity.class);
				i.putExtra("saleType", "0");
				startActivity(i);
			}
		});
		View productType1 = findViewById(R.id.product_create_type_1);
		productType1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(AssistantActivity.this, ProductCreateActivity.class);
				i.putExtra("saleType", "1");
				startActivity(i);
			}
		});
		View productType2 = findViewById(R.id.product_create_type_2);
		productType2.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(AssistantActivity.this, ProductCreateActivity.class);
				i.putExtra("saleType", "2");
				startActivity(i);
			}
		});
		View purchaseType = findViewById(R.id.purchase_create_type_0);
		purchaseType.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(AssistantActivity.this, PurchaseCreateActivity.class);
				startActivity(i);
			}
		});
		View supportType0 = findViewById(R.id.support_create_type_0);
		supportType0.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(AssistantActivity.this, DeliveryCreateActivity.class);
				startActivity(i);
			}
		});
		View supportType1 = findViewById(R.id.support_create_type_1);
		supportType1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent i = new Intent(AssistantActivity.this, SubscribeCreateActivity.class);
				startActivity(i);
				
			}
		});
		View supportType2 = findViewById(R.id.support_create_type_2);
		supportType2.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				startDial();
			}
		});
	}
	
	@Override
	public void onBackPressed() {
		super.onBackPressed();
	    this.finish();
	}
}
